function [shape] = poly_rotate(shape,x,y,a)
%% Poly rotate
%       Rotate a given polygon in 'shape' about the location [x,y] by angle
%       a (in degrees). 

%%
% Determine if shape is a legit x,y matrix
test=size(shape);
if (test(1,2) ~= 2)
    error('>>> Shape must be of size [n,2]')
    % RETURN
end

%%
% Convert a to degrees
a = a*pi/180;


% Move matrix to origin of point
shape(:,1)=shape(:,1)-x;
shape(:,2)=shape(:,2)-y;

% Preform rotation
rot = [cos(a),-sin(a);sin(a),cos(a)];
shape = shape*rot;

% Return shape to location
shape(:,1)=shape(:,1)+x;
shape(:,2)=shape(:,2)+y;
end